package com.gxa.index.controller;

import com.gxa.common.base.RespResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.BoundHashOperations;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.ValueOperations;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
public class PageViewController {
    @Autowired
    private RedisTemplate redisTemplate;

    static Integer count;

    @RequestMapping("/count")
    public RespResult pageView(Integer id){
        //String类型
        ValueOperations operations=redisTemplate.opsForValue();
        operations.set("kk",id);
        //设置过期时间
        operations.set("kk2",10,10, TimeUnit.MINUTES);
        //hash类型
        BoundHashOperations boundHashOperations = redisTemplate.boundHashOps("值");
        boundHashOperations.put("name","kk");
        boundHashOperations.put("age","12");
        //获取整个map对象
        boundHashOperations.entries();
        return RespResult.success();

    }
}
